package edu.ccut.saturn.studio.naviagtor.properties;

import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.navigator.IDescriptionProvider;
import org.eclipse.ui.navigator.INavigatorContentService;

public class SaturnTabbedPropertySheetTitleProvider extends LabelProvider  {

	private ILabelProvider labelProvider;

	private IDescriptionProvider descriptionProvider;

	/**
	 * Constructor for CommonNavigatorTitleProvider.
	 */
	public SaturnTabbedPropertySheetTitleProvider() {
		super();
		IWorkbenchPart part = PlatformUI.getWorkbench()
				.getActiveWorkbenchWindow().getActivePage().getActivePart();

		INavigatorContentService contentService = (INavigatorContentService) part
				.getAdapter(INavigatorContentService.class);

		if (contentService != null) {
			labelProvider = contentService.createCommonLabelProvider();
			descriptionProvider = contentService
					.createCommonDescriptionProvider();
		} 
	}

	public Image getImage(Object object) {
		return labelProvider != null ? labelProvider.getImage(object) : null;
	}

	public String getText(Object object) {
		return descriptionProvider != null ? descriptionProvider
				.getDescription(object) : null;
	}

}
